#region Namespaces

using System;

#endregion

namespace Vibstudio.X4NET.Xml.Linq
{
    public class XDeclaration
    {
        public XDeclaration(string version, string encoding, string standalone)
        {
            Version = version;
            Encoding = encoding;
            Standalone = standalone;
        }

        public XDeclaration(XDeclaration other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            Version = other.Version;
            Encoding = other.Encoding;
            Standalone = other.Standalone;
        }

        public string Encoding { get; set; }

        public string Standalone { get; set; }

        public string Version { get; set; }

        public override string ToString()
        {
            return String.Concat("<?xml",
                                 Version != null ? " version=\"" : null,
                                 Version,
                                 Version != null ? "\"" : null,
                                 Encoding != null ? " encoding=\"" : null,
                                 Encoding,
                                 Encoding != null ? "\"" : null,
                                 Standalone != null ? " standalone=\"" : null,
                                 Standalone,
                                 Standalone != null ? "\"" : null,
                                 "?>");
        }
    }
}